When an action is atomic it means the entire action happens without interruption. For example, if I have:
driver.get(url); waitForLoadingToFinish(); This code appears to be fine. If we assume the waitForLoadingToFinish() works then this is good. However, what happens if the page loads so fast that the loading icon does not appear. So sometimes I need to wait for the icon to appear then wait for it to disappear. Other times if I wait for it to appear it never appears. The code inside waitForLoadingToFinish() is NOT atomic. It is checking for two or more events but not at once. It will check the first event, then check the second event. If something changes between the first check and the second check it could cause a deadlock or starvation (pre-emptive operating system terms) to occur. There are ways to deal with preventing deadlock or starvation but now you are making your code more difficult to maintain. Usually what happens is you get the test to work with the timing on your development machine. When you push it to the build environment it fails because it has different timing. Or it works for one developer but not another developer. Or it works for months then you get a system update, timing changes and the test starts failing 50% of the time. Additionally, if you don't fully understand the entire technology stack, you might have missed a scenario and the error condition still exists. The error condition might happen less frequently but this is really frustrating. If the test suite fails occasionally and it turns out to be a bad test, the developers will start to mistrust the tests. If the code is always working and the tests are occasionally failing, the developers will start trusting their coding ability and ignoring the test results.
5 Comments
Many tester waste a lot of time over the script by wrong method call. A method call, especially one which goes from the client (Selenium bindings) to the code embedded in the web browser (WebDriver) is expensive (time consuming).
Here I would like to write down a typical example : The executing time of: driver.findElement("parent").findElement("child"); Is a lot slower than: driver.findElement("parent child"); Let's think about CSS. Adding a few milliseconds per web element find doesn't seem like a lot but in an entire test suite it could easily double or triple execution time. Last 5 and 6 November 2011 was the Saigon MDC 2011(http://www.mobiledevcamp-vn.org/?lang=en). Over I took a training session on android webdriver automation test training session. That training's session slides are attached here. If you missed that training session then also I hope this slide will help your learning invention . Cheers !
Today I am going to share a very interesting topic with you. Android phone, what do you think when every I tell in front of you? Interesting or some even can tell me “no this is quite boring”. But if in over all we examine that then this is quite popular among the people. In north American countries iphone is dominating there is a little use of android. But if we consider in Asia then android is the king of this area. Because a lot of people are using and really become a fan of this. So whenever something being popular the depend software development rate also increase. So now days a lot of android app is developing all over the Asia. Even those software companies which are from West they are also investing in android app developing. • So whenever we are having a lot of android software developing then we have to perform the test operation on them too to ensure the quality. Right? Unlucky there were no tools for real test automation in android even in 2009 and 2010. Really surprising but true. Now we are in the pipeline of android test automation tools. Let’s think now how people normally test a mobile or android app? • You come up with a test plan based on the features of the application. • You take into account the requirements of the platform. • For Android, we're talking about stability, responsiveness, accessibility, performance, elegance, security, and so on. • it varies by company as it always has, but the fundamentals are the same. It requires a budget, personnel, hardware, and will. That is something like that. Previously when we use to do android test automation then we need the following materials to perform the test automation. Such as: · Android main project · Test project · IDE · Some tools even need the permission inside the mailfest.xml file. Now here is the point is. Many project is not develop in one company and submit to another company to test. So now your client how can belive in you that you will not steal the code from that project? Haha. Maybe you are thinking, “What nonsense are you saying? I never think so bad way!” But this is ture that maybe you are not thinking but many other people are there to think quite much about this. Even if I ask you how can you trust other people with your project. This was pretty hard for both side. So android test automation test was not speed up. Because people can’t trust each other. So they just project apk and confirm manual testing. But I belive that there is no limitation is not a real limitation. If we effort then we can overcome that too. So now totally I am going to tell you one new technology where you don’t need any project just apk which is enough to do test automation. So lets list which things are need for this automation • Android environment • IDE • Application.apk You must be thinking how this is possible. Right? Soon I will post a video demo on this. There are several steps required to prepare the android device or emulator, the environment and the computer. These include: · Installing android-server.apk (the actual filename may differ e.g. if you use a prebuilt version it will include the release name). If you want to use an emulator, we currently recommend using one with Android 2.2 installed. The server doesn’t support earlier versions any more (it used to but limitations with the platform e.g. lack of support for XPath meant the project team have chosen to target a minimum of 2.2). There’s currently an issue with the Java-to-JavaScript bridge in version 2.3 of the emulator, so again we don’t recommend using it currently.) · Configuring port forwarding so your tests can communicate with the device or running instance of the emulator. · Starting the WebDriver Server on the Android emulator (or on a device). Configuring your eclipse project You will need to include the various jar files from the selenium project in order for your tests to use ‘RemoteWebdriver’. The AndroidDriver implements the RemoteWebdriver protocol. You can download a zip file from the selenium project site http://code.google.com/p/selenium/downloads/list e.g. selenium-java-2.0b1.zip currently. This file needs to be unzipped, which will unpack to 2 selenium jar files (the code and the javadoc documentation) and a series of 27 other jar files. All these files need to be added to the build path in your eclipse project. I suggest copying all the files into a common libs folder for your project. First, let's create an Android Virtual Device (AVD): $cd ~/android_sdk/tools/ $./android create avd -n my_android -t 12 -c 100M -n: specifies the name of the AVD. -t: specifies the platform target. For an exhaustive list of targets, run: ./android list targets Make sure the target level you selected corresponds to a supported SDK platform. -c: specifies the SD card storage space. When prompted "Do you wish to create a custom hardware profile [no]" enter "no". Now, start the emulator. This can take a while, but take a look at the FAQ below for tips on how to improve performance of the emulator. $./emulator -avd my_android & Install the WebDriver APKEvery device or emulator has a serial ID. Run this command to get the serial ID of the device or emulator you want to use: $~/android_sdk/platform-tools/adb devices Download the Android server from selenium download page To install the application do: $./adb -s <serialId> -e install -r android-server.apk Make sure you are allowing installation of application not coming from Android Market. Go to Settings -> Applications, and check "Unknown Sources". Start the Android WebDriver application through the UI of the device or by running this command: $./adb -s <serialId> shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity You can start the application in debug mode, which has more verbose logs by doing: $./adb -s <serialId> shell am start -a android.intent.action.MAIN -n org.openqa.selenium.android.app/.MainActivity -e debug true Sample Code: just put that inside a class and check the magic, Run the Testsimport junit.framework.TestCase; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.android.AndroidDriver; public class OneTest extends TestCase { public void testGoogle() throws Exception { WebDriver driver = new AndroidDriver(); // And now use this to visit Google driver.get("http://www.google.com"); // Find the text input element by its name WebElement element = driver.findElement(By.name("q")); // Enter something to search for element.sendKeys("Cheese!"); // Now submit the form. WebDriver will find the form for us from the element element.submit(); // Check the title of the page System.out.println("Page title is: " + driver.getTitle()); driver.quit(); } }
still confused ??? haha. Really no problem. Check my video tutorial on android webdriver. You will have your all questions answer. |
AuthorI am Masud Parvez. Working as IT Senior Project Manager for RMIT University. Previously I built and run a distributed Test Center. My success was to turn that in to one of the most successful business units of the company. Categories
All
|